<template>
    <view>
        <view class="resultBox">
            <u-empty
                mode="car"
                :icon="resultIcon"
                :text="resultText"
                textColor="#333"
                textSize="32rpx"
                width="370rpx"
                height="296rpx"
            />
            <u-button
                text="查看订单"
                :customStyle="buttonCustomStyle"
                :hairline="false"
                shape="circle"
                @click="checkOrder"
            />
        </view>
    </view>
</template>

<script>
import { getByOrderNumSalesman } from "@/api/order.js";
export default {
    data() {
        return {
            options: null,
            resultText: "支付结果尚未返回，请稍后在订单中查看",
            resultIcon: "/pages_shop1/static/img/shop/payResultwating.png",
            buttonCustomStyle: {
                width: "216rpx",
                height: "58rpx",
                backgroundColor: "#588BF3",
                color: "#fff",
                fontSize: "24rpx",
                marginTop: "40rpx",
            },
        };
    },
    onLoad(options) {
        console.log(options);
        this.options = options;
        if (this.options.status === "success") {
            uni.$u.sleep(1000).then(() => {
                this.getOrderDetail(this.options.orderNum);
            });
        } else if (this.options.status === "fail") {
            this.resultText = "支付失败：用户取消支付";
            this.resultIcon = "/pages_shop1/static/img/shop/payResultFail.png";
        }
    },
    methods: {
        checkOrder() {
            const that = this;
            uni.$u.route({
                type: "redirectTo",
                url: "/pages_shop1/order/order_detail/order_detail",
                params: {
                    id: that.options.orderNum,
					detailStatus:0,//1：用户中心进去的  0：客户端领取记录进去的
                },
            });
        },
        async getOrderDetail(orderNum) {
            const result = await getByOrderNumSalesman(orderNum);
            this.resultText = "支付成功";
            this.resultIcon =
                "/pages_shop1/static/img/shop/payResultSuccess.png";
        },
    },
};
</script>

<style lang="scss" scoped>
.resultBox {
    position: absolute;
    height: 50vh;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    margin: auto; /* 有了这个就自动居中了 */
}
</style>
